/**
 * Created by felix on 2017/3/26.
 */
import React from 'react';
import { Form } from 'antd';

export const defaultItemLayout = {
    labelCol: {
        xs: { span: 6 },
        sm: { span: 6 },
        md: { span: 4 },
        lg: { span: 4 },
        xl: { span: 2 },
    },
    wrapperCol: {
        xs: { span: 16 },
        sm: { span: 14 },
        md: { span: 10 },
        lg: { span: 10 },
        xl: { span: 8 },
    },
};

/**
 * FormItem生成器，
 * @param label         表单名称
 * @param itemLayout    响应式布局，可以单独定义
 * @param children      表单实体
 * @param other         其他参数
 * @returns {XML}       返回antd的FormItem组件
 * @constructor
 */
function FormItem({ itemLayout = defaultItemLayout, children, ...other }) {
    return (
        <Form.Item
            {...itemLayout}
            {...other}
        >
            {children}
        </Form.Item>
    );
}
export default FormItem;

